grammar debugMeWithAntlrWorks;
 options{backtrack=true; memoize=true;} 



parse :
	 result=ruleMModel
	 // Always return the root node! This prevents that this method is called multiple times
	 // with interesting side effects.
	 EOF
;

ruleMModel 

:
((ruleMComposite)

(ruleTemplate)*
)
;

ruleMComposite 

:
(('composite')

(RULE_ID)?

(('[')

(ruleMSWT)

(('|')

(ruleMSWT)
)*

(']')
)?

(('(')

((('layout')

(':')

(ruleMLayout)
)
	|
(('layoutData')

(':')

(ruleMLayoutData)
)
	|
(('bgColor')

(':')

(ruleMColor)
)
	|
(('fgColor')

(':')

(ruleMColor)
)
	|
(('font')

(':')

(ruleMFont)
)
)*

(')')
)?

('{')

(ruleMControl)*

('}')
)
;

ruleMColor 

:
((RULE_INT)

(',')

(RULE_INT)

(',')

(RULE_INT)
)
;

ruleMControl 
:
        temp_mcomposite=ruleMComposite 	|        temp_mbutton=ruleMButton 	|        temp_mlabel=ruleMLabel 	|        temp_mtext=ruleMText 	|        temp_mcombo=ruleMCombo 	|        temp_templateusage=ruleTemplateUsage 	;

ruleMButton 

:
(('button')

(RULE_ID)?

(('[')

(ruleMSWT)

(('|')

(ruleMSWT)
)*

(']')
)?

(('(')

((('layoutData')

(':')

(ruleMLayoutData)
)
	|
(('bgColor')

(':')

(ruleMColor)
)
	|
(('fgColor')

(':')

(ruleMColor)
)
	|
(('font')

(':')

(ruleMFont)
)
)*

(')')
)?

('{')

(ruleParameter)

('onClick')

(':')

(ruleMActionHandler)

('}')
)
;

ruleMLabel 

:
(('label')

(RULE_ID)?

(('[')

(ruleMSWT)

(('|')

(ruleMSWT)
)*

(']')
)?

(('(')

((('layoutData')

(':')

(ruleMLayoutData)
)
	|
(('bgColor')

(':')

(ruleMColor)
)
	|
(('fgColor')

(':')

(ruleMColor)
)
	|
(('font')

(':')

(ruleMFont)
)
)*

(')')
)?

('{')

(ruleParameter)

('}')
)
;

ruleParameter 
:
        temp_constant=ruleConstant 	|        temp_variable=ruleVariable 	;

ruleConstant 

:
(RULE_STRING)
;

ruleVariable 

:
(RULE_ID)
;

ruleTemplate 

:
(('template')

(RULE_ID)

('(')

((RULE_ID)

((',')

(RULE_ID)
)*
)?

(')')

('{')

(ruleMControl)+

('}')
)
;

ruleTemplateUsage 

:
((RULE_ID
)

(RULE_ID)

('(')

((RULE_STRING)

((',')

(RULE_STRING)
)*
)?

(')')
)
;

ruleMText 

:
(('text')

(RULE_ID)?

(('[')

(ruleMSWT)

(('|')

(ruleMSWT)
)*

(']')
)?

(('(')

((('layoutData')

(':')

(ruleMLayoutData)
)
	|
(('bgColor')

(':')

(ruleMColor)
)
	|
(('fgColor')

(':')

(ruleMColor)
)
	|
(('font')

(':')

(ruleMFont)
)
)*

(')')
)?

(('{')

(ruleParameter)

('}')
)?
)
;

ruleMLayout 
:
        temp_mgridlayout=ruleMGridLayout 	;

ruleMLayoutData 
:
        temp_mgriddata=ruleMGridData 	;

ruleMGridLayout 

:
(('grid')

(('(')

(RULE_INT)?

('equalWidth')?

(('wMargin')

('=')

(RULE_INT)
)?

(('hMargin')

('=')

(RULE_INT)
)?

(')')
)?
)
;

ruleMGridData 

:
(('gridData')

(('(')

((ruleMSWT)

(',')

(ruleMSWT)
)?

((('wHint')

('=')

(RULE_INT)
)
	|
(('hHint')

('=')

(RULE_INT)
)
	|
(('hSpan')

('=')

(RULE_INT)
)
	|
(('vSpan')

('=')

(RULE_INT)
)
	|
('grabHSpace')
	|
('grabVSpace')
)*

(')')
)?
)
;

ruleMSWT  :
		 'beginning'
		 
	 |		 'center'
		 
	 |		 'end'
		 
	 |		 'fill'
		 
	 |		 'default'
		 
	 |		 'border'
		 
	 |		 'single'
		 
	 |		 'multi'
		 
	 |		 'check'
		 
	 |		 'radio'
		 
	 |		 'push'
		 
	 |		 'toggle'
		 
	 |		 'password'
		 
	 |		 'readOnly'
		 
	 |		 'separator'
		 
	 |		 'bold'
		 
	 |		 'italic'
		 
	 |		 'normal'
		 
;

ruleMActionHandler 

:
(('bundle')

('=')

(ruleQID)

('class')

('=')

(ruleQID)
)
;

ruleQID :

(((RULE_ID
)
(((		'.' 
)
(RULE_ID
))
)*)
)

;

ruleMCombo 

:
(('combo')

(RULE_ID)?

(('[')

(ruleMSWT)

(('|')

(ruleMSWT)
)*

(']')
)?

(('(')

((('layoutData')

(':')

(ruleMLayoutData)
)
	|
(('bgColor')

(':')

(ruleMColor)
)
	|
(('fgColor')

(':')

(ruleMColor)
)
	|
(('font')

(':')

(ruleMFont)
)
)*

(')')
)?

('{')

(ruleParameter)

(('|')

(ruleParameter)
)*

(('onClick')

(':')

(ruleMActionHandler)
)?

('}')
)
;

ruleMFont 

:
((RULE_STRING)?

((RULE_INT)

('px')
)?

((ruleMSWT)

(('|')

(ruleMSWT)
)*
)?
)
;

RULE_ID :

	 ('^')?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
	 
;

RULE_STRING :

	 '\"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | ~('\\'|'\"') )* '\"' |
	 '\'' ( '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | ~('\\'|'\'') )* '\''
	 
;

RULE_INT :

	 ('-')?('0'..'9')+
	 
;

RULE_WS :

	 (' '|'\t'|'\r'|'\n')+ {$channel=HIDDEN;}
	 
;

RULE_ML_COMMENT :

	 '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
	 
;

RULE_SL_COMMENT :

	 '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
	 
;

